//
//  ViewController.m
//  18-SQLite
//
//  Created by 李昊林 on 16/8/8.
//  Copyright © 2016年 李昊林. All rights reserved.
//

#import "ViewController.h"
#import "SQLiteDataBaseManager.h"
#import "Student.h"
@interface ViewController ()
@property (nonatomic,strong) SQLiteDataBaseManager *dataBaseManager;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _dataBaseManager = [SQLiteDataBaseManager shareManager];
    //SQLite3
    //注意使用SQLite需要引用sqlite3.0.tdb
    //libsqlite3.0.tdb和libsqlite3.tdb的区别
    //libsqlite3.0.tdb是libsqlite3.tdb的替身文件，防止用户互删
  
}
- (IBAction)openSQLite:(id)sender {
    [_dataBaseManager openSQLite3];
    
    
}
- (IBAction)closeSQLite:(id)sender {
    [_dataBaseManager closeSQLite3];
    
}
- (IBAction)createTable:(id)sender {
    [_dataBaseManager createTable];
}
- (IBAction)insertStu:(id)sender {
    [_dataBaseManager insertStu:[Student new]];
}
- (IBAction)deleateStu:(id)sender {
//    Student *stu = [[Student alloc] init];
//    stu.stu_id = 12;
//    stu.stu_name = @"XX";
    [_dataBaseManager deleateAll];
}
- (IBAction)updateName:(id)sender {
    [_dataBaseManager updateOldName:@"XX" newName:@"王道林"];

}
- (IBAction)selectAll:(id)sender {
    NSArray * array = [_dataBaseManager selectAll];
    NSLog(@"%ld",array.count);
    NSLog(@"%@",array);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
